#!/usr/bin/perl
use strict;
use warnings;
use File::Find;

#只接受一个参数
my $argc = @ARGV;

if($argc < 2) {
	print "\tusage : ./delete_c_cpp_unuse_code.plx <src path> <dst path> [<file filter string>]\n";
	print "\texample : ./delete_c_cpp_unuse_code.plx /a /b *.c *.h *.cpp\n";
	print "If not describe file filter args.default to fileter *.c *.h *.cpp\n";
	print "\texample : ./delete_c_cpp_unuse_code.plx /a /b\n";
} else {
	&delete_unuse(@ARGV);
}

my @global_filter;

sub delete_unuse {
	my($src,$dst,@filter_arr) = @_;
	#print "src:$src,dst:$dst\n";
	my $filter_count = @filter_arr;
	if($filter_count == 0) {
		print "filter empty will use default!\n";
		@filter_arr = qw(
			*.c
			*.h
			*.cpp
		);
	}
	my $bad_format = 0;
	foreach(@filter_arr) {
		if(!m/\*\.[\w|\d]+/) {
			print "bad format : $_\n";
			$bad_format = 1;
		} else {
			print "get: $_\n";
		}
	}
	#这里需要对filter_arr进行迭代找到所有满足条件的
	#文件
	if(!$bad_format) {
		@global_filter = @filter_arr;
		find(&file_scan,$src);
	}
}

sub file_scan {
	#foreach(@global_filter) {
	#	s/^\*/\\/;
	#	print "$_\n";
	#	if(m/$_/) {
	#		print "get:$File::Find::name\n";
	#	}
	#}
	print "get:$File::Find::name\n";
}

